// JavaScript Document
function aqifont(){
	if(toAqi<=50){
		return "优";
		}
	else if(toAqi>50&&toAqi<=100){
		return "良";
		}
	else if(toAqi>100&&toAqi<=150){
		return "轻度污染";
		}
	else if(toAqi>150&&toAqi<=200){
		return "中度污染";
		}
	else if(toAqi>200&&toAqi<=300){
		return "重度污染";
		}
	else if(toAqi>300){
		return "严重污染";
		}
	}
function getweather(){
	/*
	var name = document.getElementById("search").value;
	if(name == ""){
		alert("不能输入空值哦~");
		return;
		}
	$("#hide").fadeOut(500);
	*/
	$("#nowweather").show(700);
	$(".window").hide(700);
	cname = document.getElementsByTagName("h1")[0];
	cname.innerHTML = "<font face='微软雅黑'>一叶金陵天气网</font>";
	var shi = remote_ip_info["city"];
	city = String(shi);
	$("#city").html(city);
	 $.getJSON("http://wthrcdn.etouch.cn/weather_mini",
		{city:city},function(json){
			nTem = json.data.wendu;
			Ganmao = json.data.ganmao;
			toAqi = json.data.aqi;
			toType = json.data.forecast[0].type;
			toFeng = json.data.forecast[0].fengli;
			//今天的基本信息
			nTem = Number(nTem);
			toAqi = Number(toAqi);
			toType = String(toType);
			toFeng = String(toFeng);
			
			$("#nowTem").html("<font face = '微软雅黑' size='6'>"+nTem+"</font>");
			$("#nowAqi").html("<font face = '微软雅黑' size='6'>"+toAqi+"&nbsp;&nbsp;</font><font face = '微软雅黑' size=5>"+aqifont()+"</font>");
			$("#nowType").html("<font face = '微软雅黑' size='6'>"+toType+"</font>");
			$("#nowFeng").html("<font face = '微软雅黑' size='6'>"+toFeng+"</font>");
			
			})
	}

function nextweather(){
	$("#nowweather").hide(700);
	$(".window").show(700);
	$.getJSON("http://wthrcdn.etouch.cn/weather_mini",
		{city:city},function(json){
			if( json.desc!="OK")
			{
				alert("Sorry~好像出了点问题耶。待会再来看看吧！");
			}
			cName = json.data.city;
			nTem = json.data.wendu;
			Ganmao = json.data.ganmao;
			toAqi = json.data.aqi;
			//今天的基本信息
			
			cName = "当前城市：" + String(cName);
			Ganmao = String(Ganmao);
			nTem = Number(nTem);
			toAqi = Number(toAqi);
			cname = document.getElementsByTagName("h1")[0];
			cname.innerHTML = cName;
			
			
			toFengxiang = json.data.forecast[0].fengxiang;
			toFengli = json.data.forecast[0].fengli;
			toGaowen = json.data.forecast[0].high;
			toDiwen = json.data.forecast[0].low;
			toType = json.data.forecast[0].type;
			toDate = json.data.forecast[0].date;
			//今天的详细数据(1)
			
			secFengxiang = json.data.forecast[1].fengxiang;
			secFengli = json.data.forecast[1].fengli;
			secGaowen = json.data.forecast[1].high;
			secDiwen = json.data.forecast[1].low;
			secType = json.data.forecast[1].type;
			secDate = json.data.forecast[1].date;
			//明天的详细数据(2)
			
			thrFengxiang = json.data.forecast[2].fengxiang;
			thrFengli = json.data.forecast[2].fengli;
			thrGaowen = json.data.forecast[2].high;
			thrDiwen = json.data.forecast[2].low;
			thrType = json.data.forecast[2].type;
			thrDate = json.data.forecast[2].date;
			//后天的详细数据(3)
			
			fouFengxiang = json.data.forecast[3].fengxiang;
			fouFengli = json.data.forecast[3].fengli;
			fouGaowen = json.data.forecast[3].high;
			fouDiwen = json.data.forecast[3].low;
			fouType = json.data.forecast[3].type;
			fouDate = json.data.forecast[3].date;
			//大后天的详细数据(4)
			
			fifFengxiang = json.data.forecast[4].fengxiang;
			fifFengli = json.data.forecast[4].fengli;
			fifGaowen = json.data.forecast[4].high;
			fifDiwen = json.data.forecast[4].low;
			fifType = json.data.forecast[4].type;
			fifDate = json.data.forecast[4].date;
			//大大后天的详细数据(5)
			
			yesFengxiang = json.data.yesterday.fx;
			yesFengli = json.data.yesterday.fl;
			yesGaowen = json.data.yesterday.high;
			yesDiwen = json.data.yesterday.low;
			yesType = json.data.yesterday.type;
			yesDate = json.data.yesterday.date;
			//昨天的详细数据
			
			yesGaowen = yesGaowen.match(/\d+/g);
			yesDiwen = yesDiwen.match(/\d+/g);
			toGaowen = toGaowen.match(/\d+/g);
			toDiwen = toDiwen.match(/\d+/g);
			secGaowen = secGaowen.match(/\d+/g);
			secDiwen = secDiwen.match(/\d+/g);
			thrGaowen = thrGaowen.match(/\d+/g);
			thrDiwen = thrDiwen.match(/\d+/g);
			fouGaowen = fouGaowen.match(/\d+/g);
			fouDiwen = fouDiwen.match(/\d+/g);
			fifGaowen = fifGaowen.match(/\d+/g);
			fifDiwen = fifDiwen.match(/\d+/g);
			//alert(yesDate);
			
			yDate = String(yesDate);
			yGaowen = Number(yesGaowen);
			yType = String(yesType);
			yDiwen = Number(yesDiwen);
			ydate = document.getElementsByTagName("h2")[0];
			ygaowen = document.getElementsByTagName("h4")[0];
			ydiwen = document.getElementsByTagName("h4")[1];
			ydate.innerHTML = yDate;
			ygaowen.innerHTML = yGaowen;
			ydiwen.innerHTML = yDiwen;
			
			if(yType.indexOf("雨")>=0){
				var yTq = "<img src='../src/img/rain.png'/>"
				}
			else if(yType.indexOf("晴")>=0){
				var yTq = "<img src='../src/img/sunny.png'/>"
				}
			else if(yType.indexOf("云")>=0){
				var yTq = "<img src='../src/img/cloud.png'/>"
				}
			else if(yType.indexOf("雪")>=0){
				var yTq = "<img src='../src/img/snow.png'/>"
				}
			else if(yType.indexOf("雾")>=0){
				var yTq = "<img src='../src/img/fog.png'/>"
				}
			else if(yType.indexOf("阴")>=0){
				var yTq = "<img src='../src/img/yin.png'/>"
				}
				ytype = document.getElementsByTagName("h3")[0];
				ytype.innerHTML = yTq;
			//1
			
			tDate = String(toDate);
			toType = String(toType);
			tGaowen = Number(toGaowen);
			tDiwen = Number(toDiwen);
			todate = document.getElementsByTagName("h2")[1];
			togaowen = document.getElementsByTagName("h4")[2];
			todiwen = document.getElementsByTagName("h4")[3];
			if(toType.indexOf("雨")>=0){
				var toTq = "<img src='../src/img/rain.png'/>"
				}
			else if(toType.indexOf("晴")>=0){
				var toTq = "<img src='../src/img/sunny.png'/>"
				}
			else if(toType.indexOf("云")>=0){
				var toTq = "<img src='../src/img/cloud.png'/>"
				}
			else if(toType.indexOf("雪")>=0){
				var toTq = "<img src='../src/img/snow.png'/>"
				}
			else if(toType.indexOf("雾")>=0){
				var toTq = "<img src='../src/img/fog.png'/>"
				}
			else if(toType.indexOf("阴")>=0){
				var toTq = "<img src='../src/img/yin.png'/>"
				}
				totype = document.getElementsByTagName("h3")[1];
				totype.innerHTML = toTq;
				todate.innerHTML = tDate;
				togaowen.innerHTML = tGaowen;
				todiwen.innerHTML = tDiwen;
			//2
			
			sDate = String(secDate);
			sType = String(secType);
			sGaowen = Number(secGaowen);
			sDiwen = Number(secDiwen);
			secdate = document.getElementsByTagName("h2")[2];
			secgaowen = document.getElementsByTagName("h4")[4];
			secdiwen = document.getElementsByTagName("h4")[5];
			secdate.innerHTML = sDate;
			secgaowen.innerHTML = sGaowen;
			secdiwen.innerHTML = sDiwen;
			if(secType.indexOf("雨")>=0){
				var secTq = "<img src='../src/img/rain.png'/>"
				}
			else if(secType.indexOf("晴")>=0){
				var secTq = "<img src='../src/img/sunny.png'/>"
				}
			else if(secType.indexOf("云")>=0){
				var secTq = "<img src='../src/img/cloud.png'/>"
				}
			else if(secType.indexOf("雪")>=0){
				var secTq = "<img src='../src/img/snow.png'/>"
				}
			else if(secType.indexOf("雾")>=0){
				var secTq = "<img src='../src/img/fog.png'/>"
				}
			else if(secType.indexOf("阴")>=0){
				var secTq = "<img src='../src/img/yin.png'/>"
				}
				sectype = document.getElementsByTagName("h3")[2];
				sectype.innerHTML = secTq;
			
			//3
			
			thDate = String(thrDate);
			thType = String(thrType);
			thGaowen = Number(thrGaowen);
			thDiwen = Number(thrDiwen);
			thrdate = document.getElementsByTagName("h2")[3];
			thrgaowen = document.getElementsByTagName("h4")[6];
			thrdiwen = document.getElementsByTagName("h4")[7];
			thrdate.innerHTML = thDate;
			thrgaowen.innerHTML = thGaowen;
			thrdiwen.innerHTML = thDiwen;
			if(thType.indexOf("雨")>=0){
				var thTq = "<img src='../src/img/rain.png'/>"
				}
			else if(thType.indexOf("晴")>=0){
				var thTq = "<img src='../src/img/sunny.png'/>"
				}
			else if(thType.indexOf("云")>=0){
				var thTq = "<img src='../src/img/cloud.png'/>"
				}
			else if(thType.indexOf("雪")>=0){
				var thTq = "<img src='../src/img/snow.png'/>"
				}
			else if(thType.indexOf("雾")>=0){
				var thTq = "<img src='../src/img/fog.png'/>"
				}
			else if(thType.indexOf("阴")>=0){
				var thTq = "<img src='../src/img/yin.png'/>"
				}
				thrtype = document.getElementsByTagName("h3")[3];
				thrtype.innerHTML = thTq;
			//4
			
			foDate = String(fouDate);
			foType = String(fouType);
			foGaowen = Number(fouGaowen);
			foDiwen = Number(fouDiwen);
			fodate = document.getElementsByTagName("h2")[4];
			fogaowen = document.getElementsByTagName("h4")[8];
			fodiwen = document.getElementsByTagName("h4")[9];
			fodate.innerHTML = foDate;
			fogaowen.innerHTML = foGaowen;
			fodiwen.innerHTML = foDiwen;
			
			if(foType.indexOf("雨")>=0){
				var foTq = "<img src='../src/img/rain.png'/>"
				}
			else if(foType.indexOf("晴")>=0){
				var foTq = "<img src='../src/img/sunny.png'/>"
				}
			else if(foType.indexOf("云")>=0){
				var foTq = "<img src='../src/img/cloud.png'/>"
				}
			else if(foType.indexOf("雪")>=0){
				var foTq = "<img src='../src/img/snow.png'/>"
				}
			else if(foType.indexOf("雾")>=0){
				var foTq = "<img src='../src/img/fog.png'/>"
				}
			else if(foType.indexOf("阴")>=0){
				var foTq = "<img src='../src/img/yin.png'/>"
				}
				//foTq = "<img src='../src/img/sunny.png'/>"
				fotype = document.getElementsByTagName("h3")[4];
				fotype.innerHTML = foTq;
			//5
			
			fiDate = String(fifDate);
			fiType = String(fifType);
			fiGaowen = Number(fifGaowen);
			fiDiwen = Number(fifDiwen);
			fidate = document.getElementsByTagName("h2")[5];
			figaowen = document.getElementsByTagName("h4")[10];
			fidiwen = document.getElementsByTagName("h4")[11];
			fidate.innerHTML = fiDate;
			figaowen.innerHTML = fiGaowen;
			fidiwen.innerHTML = fiDiwen;
			//fitype = document.getElementsByTagName("h3")[6];
			//fitype.innerHTML = fiType;
			
			if(fiType.indexOf("雨")>=0){
				var fiTq = "<img src='../src/img/rain.png'/>"
				}
			else if(fiType.indexOf("晴")>=0){
				var fiTq = "<img src='../src/img/sunny.png'/>"
				}
			else if(fiType.indexOf("云")>=0){
				var fiTq = "<img src='../src/img/cloud.png'/>"
				}
			else if(fiType.indexOf("雪")>=0){
				var fiTq = "<img src='../src/img/snow.png'/>"
				}
			else if(fiType.indexOf("雾")>=0){
				var fiTq = "<img src='../src/img/fog.png'/>"
				}
			else if(fiType.indexOf("阴")>=0){
				var fiTq = "<img src='../src/img/yin.png'/>"
				}
				fitype = document.getElementsByTagName("h3")[5];
				fitype.innerHTML = fiTq;
				
			//6
			//xj771293606			
			})
	}
